<?php

/**
 * Tools_TemplateEditObject - Edition d'un template de mail/sms
 *
 * @package
 * @author Alexis Eric
 * @copyright Copyright (c) 2012 - Erra Prod
 * @version $1.0$
 * @access public
 */
class Tools_TemplateEditObject extends Erra_Fields_Base_Object {

    function __construct($objectId, $buildArgs = null) {
        parent::__construct($objectId, $buildArgs);
        $template_content = Erra_Fields_TextArea::create('template_content')
                ->setRows(20)
                ->setCols(75)
                ->setDescription('Editer le template');

        if (!strlen($buildArgs) || !file_exists(DOCUMENT_ROOT . '/application/Views/' . $buildArgs)) {
            $buildArgs = 'Mail/Mail_AdminPasswordForgot.phtml';
        }
        $hidden_file = Erra_Fields_Hidden::create('hidden_file')
                ->setValue(base64_url_encode($buildArgs));
        $file_contents = file_get_contents(DOCUMENT_ROOT . '/application/Views/' . $buildArgs);
        $template_content->setValue($file_contents);


        $this->addFields($template_content, $hidden_file);
        $this->setReadOnly(true);
        $this->setRenderEngine('none');
    }

}

?>